#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    int removeDuplicates(vector<int>& nums)
    {
        int n = nums.size();
        if (n <= 2)
        {
            return n;
        }

        int slow = 2, fast = 2;
        while (fast < n)
        {
            if (nums[slow - 2] != nums[fast])
            {
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        return slow;
    }
};

int main()
{
    vector<int> nums = { 1, 1, 1, 2, 2, 3 };
    Solution solution;
    solution.removeDuplicates(nums);
    for (auto e : nums)
    {
        cout << e << " ";
    }
    return 0;
}